﻿using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Jocker;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MangoMes.Write.API.Applications.Login;
using MediatR;
using System.Data.Common;

namespace ManagoMes.Read.API.Applications.ProductionScheduling
{
    public class StepDescriptionHtmlHandler : IRequestHandler<StepDescriptionHtmlCommond, ResultsDTO<ProcessStep>>
    {


        private readonly IBateRepository<ProcessStep> _ProcessStep;
        private readonly Logincommonality _Logincommonality;

        public StepDescriptionHtmlHandler(IBateRepository<ProcessStep> processStep, Logincommonality logincommonality)
        {
            _ProcessStep = processStep;
            _Logincommonality = logincommonality;
        }
        /// <summary>
        /// 工序步骤显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<ResultsDTO<ProcessStep>> Handle(StepDescriptionHtmlCommond request, CancellationToken cancellationToken)
        {
            try
            {
                var list = new ResultsDTO<ProcessStep>() { Code = 0 };


                var str = "select * from processstep";
                DapperHelper dapperHelper = new DapperHelper();
                var newStep = new ProcessStep();
                 var getThey=_ProcessStep.GetAll(str, newStep, dapperHelper.MangoMesRead).ToList();
                getThey = getThey.OrderBy(x => x.Orderid).Where(x=>x.Processkid==request.Stepid).ToList();
                list.Data = getThey;
                return list;




            }
            catch (Exception)
            {

                throw;
            }
           



        }
    }
}
